bpo-7769: enable xmlrpc.server.SimpleXMLRPCDispatcher.register_function used as decorator#231
Conversation
|
@briancurtin you are involved in the issue previously so I expect your opinion. |
Doc/library/xmlrpc.server.rst
Outdated
|
|
||
| Register a function that can respond to XML-RPC requests. If *name* is given, | ||
| it will be the method name associated with *function*, otherwise | ||
| ``function.__name__`` will be used. *name* can be either a normal or Unicode |
There was a problem hiding this comment.
"a normal or Unicode string" -- this is outdated in Python 3.
Doc/library/xmlrpc.server.rst
Outdated
| ``function.__name__`` will be used. *name* is a string, and may contain | ||
| characters not legal in Python identifiers, including the period character. | ||
|
|
||
| From version 3.7, this method can also be used as a decorator. When used as |
There was a problem hiding this comment.
"From version 3.7" is not needed. There is already a versionchanged directive below.
Doc/library/xmlrpc.server.rst
Outdated
| # Print list of available methods | ||
| print(s.system.listMethods()) | ||
|
|
||
| Since version 3.7, :meth:`register_function` can also be used as a decorator. The |
There was a problem hiding this comment.
"Since version 3.7" is not needed.
| previous server example can register functions in a decorator way:: | ||
|
|
||
| from xmlrpc.server import SimpleXMLRPCServer | ||
| from xmlrpc.server import SimpleXMLRPCRequestHandler |
There was a problem hiding this comment.
Nitpick: I'd just merge two imports in one line.
There was a problem hiding this comment.
This is to be consistent with previous examples. I don't want to change this alone. :-)
|
|
||
| # Register a function under a different name, using | ||
| # register_function as a decorator. *name* can only be given | ||
| # as a keyword argument. |
There was a problem hiding this comment.
I think "can only be given as a keyword argument" is same as "keyword-only argument". :-)
There was a problem hiding this comment.
I mean there is already a shorter way to say the same thing in Python.
There was a problem hiding this comment.
I think the term "keyword-only" is applicable only to parameters, not arguments. Parameters can be positional-only (can't be defined in Python syntax), positional-or-keyword or keyword-only. Arguments can be positional or keyword.
There was a problem hiding this comment.
I changed the sentence to “*name* is keyword-only". Since *name* is wrapped with asterisks, it's referring to a parameter.
There was a problem hiding this comment.
But the name parameter is not keyword-only. It is positional-or-keyword.
The former wording looked correct to me, the changed wording don't.
Doc/library/xmlrpc.server.rst
Outdated
| # register_function as a decorator. *name* can only be given | ||
| # as a keyword argument. | ||
| @server.register_function(name='add') | ||
| def adder_function(x,y): |
There was a problem hiding this comment.
Missing space after comma.
Doc/library/xmlrpc.server.rst
Outdated
| class RequestHandler(SimpleXMLRPCRequestHandler): | ||
| rpc_paths = ('/RPC2',) | ||
|
|
||
| with SimpleXMLRPCServer(("localhost", 8000), |
There was a problem hiding this comment.
Nitpick: Use single quotes to be consistent with the rest of the example.
| server.register_introspection_functions() | ||
|
|
||
| # Register pow() function; this will use the value of | ||
| # pow.__name__ as the name, which is just 'pow'. |
There was a problem hiding this comment.
Hmm, it's not referring to the parameter here. So just leave it unchanged.
Doc/library/xmlrpc.server.rst
Outdated
| ``function.__name__`` will be used. *name* is a string, and may contain | ||
| characters not legal in Python identifiers, including the period character. | ||
|
|
||
| From version 3.7, this method can also be used as a decorator. When used as |
There was a problem hiding this comment.
"From version 3.7" is not needed.
|
Thanks @serhiy-storchaka and @berkerpeksag ! |
(Upstream is https://github.com/python/typing) - Add TYPE_CHECKING (false at runtime, true in type checkers) (upstream python#230). - Avoid error on Union[xml.etree.cElementTree.Element, str] (upstream python#229). - Repr of Tuple[()] should be 'Tuple[()]' (upstream python#231). - Add NewType() (upstream python#189).
Replace "https://bitbucket.org/stackless-dev/stackless" by "https://github.com/stackless-dev/stackless". (cherry picked from commit c11af2f)
Replace "https://bitbucket.org/stackless-dev/stackless" by "https://github.com/stackless-dev/stackless". (cherry picked from commit 49c9417)
open() uses non-binary by default. The equivalent pkg_resources.resource_stream() method opens in binary mode.
No description provided.